using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DAL;
using DTO;
using BUS;
public partial class admin_A_LoaiHang_update : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Loaddata();
        }
    }
    protected void btcapnhat_Click(object sender, EventArgs e)
    {
        if (txttenloai.Text == "")
        {
            Response.Redirect(Request.RawUrl);
        }
        try
        {
            int id = int.Parse(Request.QueryString["maloai"].ToString());
        LoaiHang_DTO lh = LOAIHANG_BUS.GetByID(id);
        lh.MaLoai = int.Parse(lmaloai.Text);
        lh.TenLoai = txttenloai.Text;
        LOAIHANG_BUS.update(lh);
        
        }
        catch (Exception ex)
        {
            Response.Redirect(Request.RawUrl);
        }
        Response.Redirect("~/admin/A_loaihang.aspx");
    }
    private void Loaddata()
    {
        //try
        //{
        //    //string tendangnhap = Session["TaiKhoan"].ToString();
        //    //if (tendangnhap != "")
        //    //{
        //    //    lit_tennguoidung.Text = Session["TaiKhoan"].ToString();

        //    //}
        //    //else
        //    //{
        //    //    Session["taikhoan"] = "";
        //    //}
        //    //int ma = int.Parse(Session["manv"].ToString());
        //    //HyperLink1.NavigateUrl = "~/admin/A_suanhanvien.aspx?id=" + ma;
        //}
        //catch (Exception ex)
        //{
        //    Response.Redirect("~/admin/A_dangnhap.aspx");
        //}

        int id = int.Parse(Request.QueryString["maloai"].ToString());
        lmaloai.Text = id.ToString();
        LoaiHang_DTO lh = LOAIHANG_BUS.GetByID(id);
        txttenloai.Text = lh.TenLoai;


    }
    protected void huy_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/admin/A_loaihang.aspx");
    }
}
